home *** CD-ROM | disk | FTP | other *** search
- #ifndef __CGradientControl_h__
- #define __CGradientControl_h__
-
- #include <QuickDraw.h>
- #include <QDOffscreen.h>
- #include <fp.h>
- #include "CBaseBindStatusCallback.h"
-
- //class CTick;
- class CGradientError;
- class CBaseControl;
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // convenience items
- //
-
- #define streq(x,y) (!strcmp((x),(y)))
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Constants
- //
-
- const Rect gZeroRect = { 0, 0, 0, 0 }; // a nil rect
- const Point gZeroPoint = { 0, 0 }; // a nil point
- const unsigned short maxRGBComponentValue = 65535; // the max value that an RGB component can hold
- const short thousandsOfColorsDepth = 16;
- const short millionsOfColorsDepth = 32;
- const int maxPropertyStringLength = 1023; // Somewhat arbitrary
-
- // an enumerated type to define the property - direction of the gradient
- typedef enum
- {
- Horizontal = 0,
- Vertical = 1,
- BothHV = 2,
- Corner = 3,
- DiagDn = 4,
- DiagUp = 5,
- PointBased = 6,
- LineBased = 7
- } enumDirection;
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Structs
- //
-
- typedef struct
- {
- Style textFace;
- short textFont;
- short textSize;
- short textMode;
- }
- FontParams;
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // CGradientControl class definition
- //
-
- class CGradientControl :
- public CBaseControl,
- public CBaseBindStatusCallback,
- public CErrorControl
- {
-
- public:
- // *** construct/destruct methods ***
- CGradientControl();
- ~CGradientControl();
-
- // *** IIUnknown methods ***
- STDMETHOD (QueryInterface)(REFIID inRefID, void** outObj);
-
- // *** IControl methods ***
- STDMETHOD(Draw) (THIS_ DrawContext* Context);
-
- // *** IPersistPropertyBag methods ***
- STDMETHOD(Load)(IPropertyBag* PropBag, IErrorLog* ErrorLog);
- STDMETHOD(LoadTextState)(IPropertyBag *PropertyBag, IErrorLog *ErrorLog);
-
- friend CGradientError;
-
- protected:
- void PrepareOffscreenWorld(const DrawContext* Context = nil);
- void MoveOnScreen(const BitMap* offscreenBitMap, const DrawContext* Context = nil);
- void ClearDisplay(void);
- Boolean LoadColor(RGBColor* theColor, char* colorString);
- BitMap* GetOffscreenBitMap(void);
- void ReleaseOffscreenBitMap(BitMap* offscreenBitMap);
-
- private:
- void RenderGradientControl(const Rect contentRect);
- double DegressToRadians(double angDegrees) { return (angDegrees / 180.0) * pi;}
- Point RotatedSize(const double angDegrees, const Point origSize);
- QDErr CreateContent(const Rect contentRect, GWorldPtr &contentGWorld);
-
- protected: // user-defineable parameters
- short mAngle; //%BD+jdo should this be a float or fixed???
- RGBColor mEndColor; // end of gradient color specifier
- enumDirection mDirection; // 0..7 direction of gradient in control - see property desc
- RGBColor mStartColor; // start of gradient color specifier
- #if defined (start_end_point)
- Point mStartPoint;
- Point mEndPoint;
- #endif
-
- private: // for our use internally:
- GWorldPtr mMainOffscreenGWorld; // where all the drawing gets done
- PixMapHandle mPixOffscreenPixMap; // pixmap of offscreen world
- Rect mRectOffscreenBounds; // bounds of offscreen world
- };
-
- #endif // __CGradientControl_h__
-
- // end-of-file
-